Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLDR-17686 change enum.valueOf to enum.forString in a couple of places #3774

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

srl295
Copy link
Member

@srl295 srl295 commented Jun 3, 2024

  • these were causing odd compilation errors on one environment

CLDR-17686

  • This PR completes the ticket.

ALLOW_MANY_COMMITS=true

- these were causing odd compilation errors on one environment
@srl295 srl295 requested a review from btangmu June 3, 2024 16:03
@srl295
Copy link
Member Author

srl295 commented Jun 3, 2024

Deleting maven cache seemed to make this error go away.
So, not sure of the cause.

pageId = PageId.valueOf(args.page);
} catch (IllegalArgumentException iae) {
pageId = PageId.forString(args.page);
if (pageId == null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this returns null if it catches the exception?

        public static PageId forString(String name) {
            try {
                return PageIdNames.forString(name);
            } catch (Exception e) {
                throw new ICUException("No PageId for " + name, e);
            }
        }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a feature of Java I wasn't familiar with

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, that would throw.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right; I misread it. It catches IllegalArgumentException then throws ICUException.

So the removal of catch (Throwable t) means that searchPathheader may throw ICUException where before it wouldn't have. That goes beyond merely changing valueOf to forString. Here q comes from an http request, so it could be anything... Line 765 of SurveyAjax will catch it:

        } catch (Throwable e) {
            SurveyLog.logException(
                    logger, e, "Error in SurveyAjax?what=" + what + ": " + e.getMessage());
            sendError(out, e);
        }

I guess that's OK, though shouldn't searchPathheader then be declared to throw ICUException? It still silently catches other exceptions further below; it just seems a little arbitrary...

pageId = PageId.valueOf(args.page);
} catch (IllegalArgumentException iae) {
pageId = PageId.forString(args.page);
if (pageId == null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right; I misread it. It catches IllegalArgumentException then throws ICUException.

So the removal of catch (Throwable t) means that searchPathheader may throw ICUException where before it wouldn't have. That goes beyond merely changing valueOf to forString. Here q comes from an http request, so it could be anything... Line 765 of SurveyAjax will catch it:

        } catch (Throwable e) {
            SurveyLog.logException(
                    logger, e, "Error in SurveyAjax?what=" + what + ": " + e.getMessage());
            sendError(out, e);
        }

I guess that's OK, though shouldn't searchPathheader then be declared to throw ICUException? It still silently catches other exceptions further below; it just seems a little arbitrary...

@macchiati
Copy link
Member

Please take a pass through PRs to make sure that they are merged before we branch (if there are other merges on the ticket)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants